# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=codelite

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=5.4.416.g5633ad2
pkgrel=1
pkgdesc="Open-source, cross platform IDE for the C/C++ programming languages (mingw-w64)"
arch=('any')
license=('GPL')
url="http://www.codelite.org"
depends=("${MINGW_PACKAGE_PREFIX}-clang"
        "${MINGW_PACKAGE_PREFIX}-libssh"
        "${MINGW_PACKAGE_PREFIX}-wxWidgets"
    )
makedepends=("${MINGW_PACKAGE_PREFIX}-boost" "${MINGW_PACKAGE_PREFIX}-webkitgtk2" "${MINGW_PACKAGE_PREFIX}-cmake")
options=(!strip staticlibs !buildflags)
source=("${_realname}::git+https://github.com/eranif/codelite.git"
        codelite-cmake-mingw.patch)
md5sums=('SKIP'
         '92a645f4f942c188855f0fe82d53077b')

pkgver() {
  cd "$_realname"
  git describe --tags | sed 's|-|.|g'
}

prepare() {
  cd "$srcdir/$_realname"
  patch -p1 -i ${srcdir}/codelite-cmake-mingw.patch
  # patch -p1 -i ${srcdir}/fix-mingw-w64-definitions.patch
  # patch -p1 -i ${srcdir}/mingw-dont-install-3rdparty.patch
}

build() {
  
  pushd ${MINGW_PREFIX} > /dev/null
  export PREFIX_DEPS=`pwd -W`
  popd > /dev/null
  
  cd $srcdir/${_realname}

  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DPREFIX=${pkgdir}${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    -DENABLE_CLANG=0 \
    -DwxWidgets_CONFIG_EXECUTABLE=${MINGW_PREFIX}/bin/wx-config \
    -DwxWidgets_wxrc_EXECUTABLE=${MINGW_PREFIX}/bin/wxrc-3.0 \
    .

  # Remove the openjpeg line once blender accepts my patch
  make V=1 # -j1 VERBOSE=1
}

package() {  
  cd "$srcdir/${_realname}"
  make install
}

